package com.ruoyi.hqfinance.service.impl;

import com.github.pagehelper.PageHelper;
import com.ruoyi.hqfinance.domain.HqSpecialHapedPartOne;
import com.ruoyi.hqfinance.domain.HqSpecialHapedPartTwo;
import com.ruoyi.hqfinance.domain.vo.HqSpecialHapedPartVo;
import com.ruoyi.hqfinance.mapper.HqSpecialHapedPartOneMapper;
import com.ruoyi.hqfinance.mapper.HqSpecialHapedPartTwoMapper;
import com.ruoyi.hqfinance.service.HqSpecialHapedPartService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class HqSpecialHapedPartServiceImpl implements HqSpecialHapedPartService {
    @Autowired
    private HqSpecialHapedPartOneMapper hqSpecialHapedPartOneMapper;
    @Autowired
    private HqSpecialHapedPartTwoMapper hqSpecialHapedPartTwoMapper;
    @Override
    public List<HqSpecialHapedPartOne> collectOne(HqSpecialHapedPartVo vo) {
        PageHelper.startPage(vo.getPageDate());
        List<HqSpecialHapedPartOne> oneList = hqSpecialHapedPartOneMapper.collectOne(vo);
        assert oneList != null;
        for (HqSpecialHapedPartOne hqSpecialHapedPartOne : oneList){
            if (vo.getTimeType() == 2){
                hqSpecialHapedPartOne.setSettleDate(vo.getStartTime() + "至" + vo.getEndTime());
            }
        }
        return oneList;
    }

    @Override
    public List<HqSpecialHapedPartTwo> collectTwo(HqSpecialHapedPartVo vo) {
        PageHelper.startPage(vo.getPageDate());
        List<HqSpecialHapedPartTwo> twoList = hqSpecialHapedPartTwoMapper.collectTwo(vo);
        assert twoList != null;
        for (HqSpecialHapedPartTwo hqSpecialHapedPartTwo : twoList){
            if (vo.getTimeType() == 2){
                hqSpecialHapedPartTwo.setSettleDate(vo.getStartTime() + "至" + vo.getEndTime());
            }
        }
        return twoList;
    }
}
